<template>
	<view class="searchBox">
		<view class="inputBox">
			<image src="./static/search.png" mode="widthFix"></image>
			<input type="text" v-model="searchValue" @input="updateInfo" :placeholder="placeholder" placeholder-style="color:#999;font-size: 14px;" />
		</view>
	</view>
</template>

<script>
	export default {
		name: "Ysearch",
		props: {
			value: {
				default: '',
				type: String
			},
			placeholder: {
				default: '请输入搜索内容',
				type: String
			},
		},
		data() {
			return {
				searchValue: '',
			};
		},
		watch: {
			value() {
				this.searchValue = this.value
			}
		},
		methods: {
			updateInfo() {
				this.$emit('update:value', this.searchValue)
				this.$emit('change', this.searchValue)
			},
		},
	}
</script>

<style lang="scss" scoped>
	.searchBox {
		display: flex;
		padding: 15rpx 30rpx;

		.inputBox {
			display: flex;
			flex: 1;
			background-color: #f2f2f2;
			padding: 15rpx;
			align-items: center;
			border-radius: 30rpx;

			image {
				margin: 0 15rpx;
				width: 30rpx;
				height: 30rpx;
			}

			input {
				flex: 1;

			}
		}
	}
</style>
